from rich.console import Console
from rich.traceback import Traceback

console = Console()

def divide(a, b):
    return a / b

try:
    divide(10, 0)
except Exception:
    # 美化错误回溯
    console.print_exception(
        show_locals=True,  # 显示局部变量
        word_wrap=True,   # 自动换行
        theme="monokai"   # 主题风格
    )